const {
  getEventData
} = getApp()
Component({
  options: {
    multipleSlots: true
  },
  properties: {
    tabsList: {
      type: Array,
      value: []
    },
    height: {
      type: String,
      value: '100vh'
    },
    type: {
      type: String,
      value: 'swiper'
    }
  },

  data: {
    tabActive: 0
  },

  methods: {
    onClickTab(event) {
      const {
        index,
        item
      } = getEventData(event)
      if (this.data.tabActive !== index) {
        this.setData({
          tabActive: index
        })
        this.triggerEvent('change', item)
      }
    },

    onSwiperChange(event) {
      this.setData({
        tabActive: event.detail.current
      })

      this.triggerEvent('change', this.data.tabsList[this.data.tabActive])
    }
  }
})